package com.sdgakj;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import org.junit.Test;

public class Sort {

	@Test
	public void insertDirect() {
		int[] a = { 49, 38, 65, 97, 76, 13, 27, 49, 78, 34, 12, 64, 1 };
		System.out.println("排序之前：");
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
		// 直接插入排序
		for (int i = 1; i < a.length; i++) {
			// 待插入元素
			int temp = a[i];
			int j;
			for (j = i - 1; j >= 0; j--) {
				// 将大于temp的往后移动一位
				if (a[j] > temp) {
					a[j + 1] = a[j];
				} else {
					break;
				}
			}
			a[j + 1] = temp;
		}
		System.out.println();
		System.out.println("排序之后：");
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}
	public static void main(String[] args) throws UnsupportedEncodingException {
		String strTest="%5B%60~%40%23%24%5E%26%2A%28%29%2B%3D%7C%7B%7D%5C%5C%5B%5C%5C%5D.%3C%3E%2F%3F%EF%BF%A5%25%E2%80%94%E2%80%94%2B%7C%7B%7D%E3%80%90%E3%80%91%5D";
		String finalString=URLDecoder.decode(strTest, "UTF-8");
		System.out.println(finalString);
	}
}
